package com.hibikiluler.javalearning.controller;

import com.hibikiluler.javalearning.entity.SysAdmins;
import com.hibikiluler.javalearning.service.SysAdminService;
import com.hibikiluler.javalearning.util.Queryinfo;
import com.hibikiluler.javalearning.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 权限数据控制层
 */

@RestController
@Api(tags = "权限数据")
@RequestMapping("/admin")
public class SysAdminController {

    @Autowired
    private SysAdminService adminService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody Queryinfo queryinfo) {
        return adminService.findPage(queryinfo);
    }

    @ApiOperation(value = "添加权限")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysAdmins admins) {
        return adminService.insert(admins);
    }

    @ApiOperation(value = "删除权限")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id) {
        return adminService.delete(id);
    }

    @ApiOperation(value = "修改权限")
    @PutMapping("/update")
    public Result update(@RequestBody SysAdmins admins) {
        return adminService.update(admins);
    }

    @ApiOperation(value = "查询所有的权限")
    @GetMapping("/findAll")
    public Result findAll() {
        return adminService.findAll();
    }
}
